{include file="public/header" /}
<link rel="stylesheet" href="/static/admin/addons/builder/css/base.css" media="all">
<link rel="stylesheet" href="/static/admin/addons/builder/css/index.css" media="all">
{if !empty($css)}
<style>
    {$css}
</style>
{/if}
<style>
    .showGrey{
        background-color:rgb(189, 245, 233);
    }
</style>
<body>
<div class="layui-fluid layui-anim layui-leftbit">
    <div class="layui-card">

        <div class="layui-form layui-card-header layuiadmin-card-header-auto" style="position: relative">
            {if !empty($showTips)}
            <div class="showTips">
                <p>正在浏览：{$title??''}</p>
            </div>
            {/if}
            {if !empty($warnTips)}
            <div class="showTips">
                <p style="font-size: 22px;width:calc(100% - 15px);border-radius: 5px;text-align: center;padding: 10px">
                    温馨提示：{$warnTips??''}</p>
            </div>
            {/if}
            {if $search}
            <div class="nav_search">
                {table:search field='$search'/}
            </div>
            {/if}
            <div style="position: relative">
                {if !empty($search_list)}
                <form class="layui-form search-form search_list layui-anim layui-anim-downbit"
                      lay-filter="search-badge-form">
                    <div class="layui-row">
                        {foreach name="search_list" item="vo"}
                        <div class="layui-badge-parent layui-col-xs12">
                            <input type="hidden" class="layui-badge-hidden" name="{$vo.filed}" value=""/>
                            <label class="layui-form-label layui-badge-label">{$vo.title}</label>
                            <div class="layui-badge-child">
                                {if empty($vo.all) || !$vo.all}
                                <span class="layui-badge-rim layui-badge-search active">全部</span>
                                {/if}
                                {foreach name="vo.child" item="val" key="key"}
                                {if !empty($vo.all)}
                                <span class="layui-badge-rim layui-badge-search <?php if(request()->get($vo['filed'],1) == $val['value']){?>active<?php }?>"
                                      data-url="{$val.url??''}" data-val="{$val.value}">{$val.title}</span>
                                {else}
                                <span class="layui-badge-rim layui-badge-search" data-url="{$val.url??''}"
                                      data-val="{$val.value}">{$val.title}</span>
                                {/if}
                                {/foreach}
                            </div>
                        </div>
                        {/foreach}
                    </div>
                </form>

                <a class="up-down up">收起<i class="layui-icon layui-icon-up"></i></a>
                {/if}
            </div>
        </div>

        <div class="layui-card-body tpl_list">
            <div style="display: flex;align-items: center;justify-content: space-between">

                <div class="layui-btn-container container" style="flex: 1">
                    {foreach name="top_buttons" item="vo"}
                    {if $vo.title == '导出'}
                    <a lay-event="exportExcel" class="{$vo.class}"
                       data-json='<?php echo json_encode($vo);?>'
                       data-title="{$nav.s_nav}"
                       data-url="{:url('getList',array_merge($Request.param,$extra_map))}&export=1">
                        <i class="layui-icon {$vo.icon}"></i>{$vo.title}
                    </a>
                    {elseif $vo.title == '导出数据'}
                    <a lay-event="_dropdown" class="{$vo.class}  {if !empty($vo.init)} table-top-init{/if}"
                       data-json='<?php echo json_encode($vo);?>'
                       data-title="{$nav.s_nav}"
                       data-url="{:url('getList',array_merge($Request.param,$extra_map))}&export=1">
                        <i class="layui-icon {$vo.icon}"></i>{$vo.title}
                    </a>
                    {else}
                    
                    <a lay-event="{if empty($vo.init)}topBtnEvent{/if}" class="{$vo.class} {if !empty($vo.init)} table-top-init{/if}" data-json='<?php echo json_encode($vo);?>'>
                        <i class="layui-icon {$vo.icon}"></i>{$vo.title}
                    </a>
                    {/if}
                    {/foreach}
                </div>

                {if $census}
                <div class="layui-row statistics_list"></div>
                {/if}
            </div>
            <table id="formTable" lay-filter="table"></table>
        </div>
    </div>
</div>
<php echo $extra_map;?>
</body>
<!-- 渲染附加的html -->
<?php echo $extra_html;?>
<input type="hidden" id="tableColumns" value='<?php echo json_encode($columns);?>'/>
<input type="hidden" id="tableUniqueStr" value="{$extra_map.tableUniqueStr}"/>
<input type="hidden" id="tableUniqueTitle" value="{$nav?$nav.s_nav:''}"/>
<input type="hidden" id="listurl" value="{:url('getList', array_merge($Request.param,$extra_map))}"/>
{include file="public/footer" /}
<script>
    $(function () {
        var a = $, t = layui.table,treeTable = layui.treeTable, tid = 'form_table',height = a(window).height(), limit = height < 1070 ? 15 : 20,listurl = "{:url('getList', array_merge($Request.param,$extra_map))}";
        treeTable.render({
            elem: '#formTable'
            , cols: [JSON.parse(a("#tableColumns").val())]
            , page: true
            , url: listurl
            , id: tid
            , totalRow: {$totalRow}
            , cellMinWidth: 120
            , autoSort: false
            , limit: limit
            , limits: [10, 15, 20, 30, 40, 60, 80, 100]
            , size: 'sm'
            ,tree: { // treeTable 特定属性集
                customName: {
                    children:'children',
                    isParent:'isParent',
                    name:'title',
                    id:'id',
                    pid:'pid',
                },
                view: {
                    indent:20,
                    showIcon:false,
                    expandAllDefault:true,
                },
            }
            , done: function (res) {
                if (res.census) {
                    var html = '';
                    for (var i = 0; i < res.census.length; i++) {
                        html += '<div>' + res.census[i].title + '：' + res.census[i].value + '</div>';
                    }
                    a(".statistics_list").html(html);
                }
                // //表格内自适应高度
                a(".layui-table-main tr").each(function (index, val) {
                    a(a(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
                    a(a(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
                });
                
                a(".abnormal_1").parent().parent().parent().addClass('showGrey')
                a(".showGrey").each(function () {
                    var index = a(this).attr('data-index');
                    a('tr[data-index="' + index + '"]').addClass('showGrey');
                });
            }
        });
    })

    function parentOpen(title, url, w, s) {
        layui.layer.closeAll();
        setTimeout(function () {
            openDrawer(title, url, w, s);
        }, 300)
    }
</script>
</html>